import request from '@/utils/request/request';
import requestForFile from '@/utils/request/requestForFile';
// import { FileRecordReq } from '@/api/model/fileModel';

// 选商方式 分页查询 （0-未指定 3-比选采购 4-竞争性谈判采购）
// 参数 billPolicy 选商策略代码（0-未指定 1-询价采购 2-单一来源采购 3-比选采购 4-竞争性谈判采购 5-招投标
// 参数 mdsItemType 物料类型代码( 1标准件 2 成品 3原材料 4 零组件 5锻铸件)
export function getPlanListForBill(data: any) {
  return request.post(
    '/api/procurement/require/plan-list/getPlanListForBill',
    data
  );
}

// 选商方式 分页查询（1-询价采购）
// 参数 billPolicy 选商策略代码（0-未指定 1-询价采购 2-单一来源采购 3-比选采购 4-竞争性谈判采购 5-招投标
// 参数 mdsItemType 物料类型代码( 1标准件 2 成品 3原材料 4 零组件 5锻铸件)
export function getPlanListForXjcg(data: any) {
  return request.post(
    '/api/procurement/require/plan-list/getPlanListForXjcg',
    data
  );
}

// 选商方式 分页查询（2-单一来源）
// 参数 billPolicy 选商策略代码（0-未指定 1-询价采购 2-单一来源采购 3-比选采购 4-竞争性谈判采购 5-招投标
// 参数 mdsItemType 物料类型代码( 1标准件 2 成品 3原材料 4 零组件 5锻铸件)
export function getPlanListForDyly(data: any) {
  return request.post(
    '/api/procurement/require/plan-list/getPlanListForDyly',
    data
  );
}

// 选商方式 分页查询（5-招投标）
// 参数 billPolicy 选商策略代码（0-未指定 1-询价采购 2-单一来源采购 3-比选采购 4-竞争性谈判采购 5-招投标
// 参数 mdsItemType 物料类型代码( 1标准件 2 成品 3原材料 4 零组件 5锻铸件)
export function getPlanListForZtb(data: any) {
  return request.post(
    '/api/procurement/require/plan-list/getPlanListForZtb',
    data
  );
}

// 更改选商方式
// billPolicy 0-未指定 1-询价采购 2-单一来源采购 3-比选采购 4-竞争性谈判采购 5-招投标
export function updateBill(data: any) {
  return request.post('/api/procurement/require/plan-list/updateBill', data);
}

// 批量审批通过、驳回（含选商方式）
// businessStatus 3-审批通过，4 -拒绝 5-商务经理接收
export function doApproval(data: any) {
  return request.post('/api/procurement/require/plan-list/doApproval', data);
}

// 招投标 上传文件数据反显
export function getTenderByPlanListNo(data: any) {
  return request.post(
    `/api/procurement/require/tender/getTenderByPlanListNo?planListNo=${data}`
  );
}

// 招投标 上传文件数据编辑
export function getTenderByPlanListNo2(data: any) {
  return request.post('/api/procurement/require/tender/saveOrUpdate', data);
}

// 确认 批量更新询价状态
export function updateInquiryStatus(data: any) {
  return request.post(
    '/api/procurement/require/plan-list/updateInquiryStatus',
    data
  );
}

// 批量更新供应商 单一来源
export function obtainSupplier(data: any) {
  return request.post(
    '/api/procurement/require/plan-supplier/obtainSupplier',
    data
  );
}

// 确认生成选商结果 单一来源
export function batchSave(data: any) {
  return request.post(
    '/api/procurement/require/supplier-chose-result/batchSave',
    data
  );
}

// 批量保存供应商选择文件 (data: FormData, params: FileRecordReq)
export function supBatchSave(data: any) {
  return request.post(
    '/api/procurement/require/plan-file/supBatchSave',
    data
    // {
    //   params,
    //   headers: {
    // 'Content-Type': 'application/form-data',
    //   },
    // }
  );
}

// 选商-采购计划供应商批量新增/更新
export function batchSaveOrUpdate(data: any) {
  return request.post(
    '/api/procurement/require/plan-supplier/batchSaveOrUpdate',
    data
  );
}

// 获取子表单数据
export function pageByPlanListNo(data: any) {
  return request.get(
    `/api/procurement/require/plan-supplier/pageByPlanListNo?planListNo=${data}`
  );
}

// 供应商信息批量删除
export function plansupplier(data: any) {
  return request.delete('/api/procurement/require/plan-supplier', {
    data,
  });
}

// 供应商中标
export function doWBid(data: any) {
  return request.post('/api/procurement/require/plan-supplier/doWBid', data);
}

// 供应商取消中标
export function doNWBid(data: any) {
  return request.post('/api/procurement/require/plan-supplier/doNWBid', data);
}

// 招投标 导出
export function exportZtb(params: any) {
  return requestForFile.get(
    '/api/procurement/require/excelOperation/exportZtb',
    {
      params,
      responseType: 'blob',
    }
  );
}

// 招投标 导入
export function importZtb(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importZtb',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}
// 选商方式确认【成品未指定导出】
export function exportCpWzd(data: any) {
  return requestForFile.post(
    '/api/procurement/require/excelOperation/exportCpWzd',
    data,
    {
      responseType: 'blob',
    }
  );
}

// 选商方式确认【成品未指定导入指定选商方式】
export function importCpWzd(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importCpWzd',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【标准件未指定导出】
export function exportBzjWzd(data: any) {
  return requestForFile.post(
    '/api/procurement/require/excelOperation/exportBzjWzd',
    data,
    {
      responseType: 'blob',
    }
  );
}

// 选商方式确认【标准件未指定导入】
export function importBzjWzd(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importBzjWzd',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【原材料未指定导出】
export function exportYclWzd(data: any) {
  return requestForFile.post(
    '/api/procurement/require/excelOperation/exportYclWzd',
    data,
    {
      responseType: 'blob',
    }
  );
}

// 选商方式确认【原材料未指定导入】
export function importYclWzd(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importYclWzd',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【零组件未指定导出】
export function exportLzjWzd(data: any) {
  return requestForFile.post(
    '/api/procurement/require/excelOperation/exportLzjWzd',
    data,
    {
      responseType: 'blob',
    }
  );
}

// 选商方式确认【零组件未指定导入】
export function importLzjWzd(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importLzjWzd',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【锻铸件未指定导出】
export function exportDzjWzd(data: any) {
  return requestForFile.post(
    '/api/procurement/require/excelOperation/exportDzjWzd',
    data,
    {
      responseType: 'blob',
    }
  );
}

// 选商方式确认【锻铸件未指定导入】
export function importDzjWzd(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importDzjWzd',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【单一来源导出供应商】
export function exportDyly(data: any) {
  return requestForFile.post(
    '/api/procurement/require/excelOperation/exportDyly',
    data,
    {
      responseType: 'blob',
    }
  );
}

// 选商方式确认【单一来源导入】
export function importDyly(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importDyly',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【比选采购导出供应商】
export function exportBxcg(params: any) {
  return requestForFile.get(
    '/api/procurement/require/excelOperation/exportBxcg',
    {
      params,
      responseType: 'blob',
    }
  );
}

// 选商方式确认【比选采购导入】
export function importBxcg(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importBxcg',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【竞争性谈判导入】
export function importCompeteNegotiation(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importCompeteNegotiation',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 选商方式确认【竞争性谈判导出】
export function exportCompeteNegotiation(params: any) {
  return requestForFile.get(
    '/api/procurement/require/excelOperation/exportCompeteNegotiation',
    {
      params,
      responseType: 'blob',
    }
  );
}

// 选商方式确认【竞争性谈判导入校验】
export function importCompeteNegotiationCheck(data: FormData) {
  return request.post(
    '/api/procurement/require/excelOperation/importCompeteNegotiationCheck',
    data,
    {
      headers: {
        'Content-Type': 'application/form-data',
      },
    }
  );
}

// 前端(含税、不含税)单价相关计算
export function execTaxCalculate(data: any) {
  return request.post(
    '/api/procurement/require/plan-supplier/execTaxCalculate',
    data
  );
}

// 转化系数相关计算
export function execUintRateCalculate(data: any) {
  return request.post(
    '/api/procurement/require/plan-supplier/execUintRateCalculate',
    data
  );
}

// 转化系数相关计算
export function batchUpdateForSimple(data: any) {
  return request.post(
    '/api/procurement/require/plan-supplier/batchUpdateForSimple',
    data
  );
}

// 校验采购计划是否存在招投标信息
export function checkTender(planListNo: any) {
  return request.get(
    `/api/procurement/require/tender/checkTender?planListNo=${planListNo}`
  );
}
// 根据采购计划编号获取关联文件列表
export function getPlanFileListByplanListNo(data: any) {
  return request.post(
    `/api/procurement/require/plan-file/getPlanFileListByplanListNo?planListNo=${data}`
  );
}
// 供应商信息批量删除
export function delPlanFile(data: any) {
  return request.delete('/api/procurement/require/plan-file', {
    data,
  });
}
// 前端税率、转换系数相关计算
export function execCalculate(data: any) {
  return request.post(
    '/api/procurement/require/plan-supplier/execCalculate',
    data
  );
}
// 前端(含税、不含税)单价相关计算
export function execTaxCalculates(data: any) {
  return request.post(
    '/api/procurement/require/quote-item/execTaxCalculate',
    data
  );
}
